package com.DreamForce.Demo.persist.IbatisImpl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.DreamForce.Demo.persist.DAO.AccountMapper;
import com.DreamForce.demo.model.Account;
@Service
public class AccountHandler {
	
	protected static Logger logger = Logger.getLogger(AccountHandler.class);
	
	@Autowired
	  private AccountMapper accountMapper;
	
	 public Account getAccount(String username) {
		    return accountMapper.getAccountByUsername(username);
		  }
	 public Account getAccount(String username, String password) {
		    Account account = new Account();
		    account.setUsername(username);
		    account.setPassword(password);
		    return accountMapper.getAccountByUsernameAndPassword(account);
		  }
	 public int getAccountVersion(String username)
	 {
		 return accountMapper.getAccountVersion(username);
	 }
	 @Transactional
	 public void insertAccount(Account account) 
	 {
		 accountMapper.insertAccount(account);
	 }
	 @Transactional
	 public void insertProfile(Account account)
	 {
		 accountMapper.insertProfile(account);
	 }
	 @Transactional
	 public void insertSignon(Account account)
	 {
		  accountMapper.insertSignon(account);
	 }
	 @Transactional
	 public boolean updateAccount(Account account)
	 {
		 accountMapper.updateAccount(account);
		 return true;
	 }
	 @Transactional
	 public boolean updateProfile(Account account){
		 accountMapper.updateProfile(account);
		 return true;
	 }
	 @Transactional
	 public boolean updateSignon(Account account)
	 {
		 accountMapper.updateSignon(account);
		 return true;
	 }

}
